//-------------------------------------------------------------------
//	Copyright (c) 2012-2014 Zhirnov Andrey
//	This file is part of the "UXGEN-ES" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#pragma once

// Engine Options //
#ifdef UXGEN_ES_CONFIG
#	include UXGEN_ES_CONFIG
#else
#	include "Base/Include/Config.h"
#endif


// Emulator //
#ifdef PLATFORM_TYPE_DESCTOP

#	define MOBILE_EMULATOR
#	define GLES_EMULATE

	// Android
#	ifdef ANDROID_EMULATOR
#		define _POSIX_EMULATOR_
#	endif

	// use SDL for iOS platform emulator
#	ifdef IOS_EMULATOR
#		define PLATFORM_SDL
//#		define _POSIX_EMULATOR_		// 
#	endif

//#	define USE_ANGLE_GLES	// TODO

#else	// not PLATFORM_TYPE_DESCTOP

	// no emulators for mobile systems
#	undef ANDROID_EMULATOR
#	undef IOS_EMULATOR

	// use SDL for iOS platform
#	ifdef PLATFORM_IPHONE
#		define PLATFORM_SDL
#	endif

#endif	// PLATFORM_TYPE_DESCTOP


// Emulate OpenGL ES 2.0 //
#if defined( USE_ANGLE_GLES ) and defined( GLES_EMULATE )
#	undef GLES_EMULATE
#	pragma message ("used 3ty party emulator, GLES_EMULATE undefined")
#endif


// Mobile Emulator //
#ifdef MOBILE_EMULATOR
#	define EMULATOR_ONLY	ARGS
#else
#	define EMULATOR_ONLY	__EMPTY_ARGS__
#endif


// Options //
#define __UX_BUILD_STATIC_LIB__
#define __UX_BUILD__
//#define UX_ZLIB_DISABLE
//#define UX_LZMA_DISABLE


// Base //
#define UX_CATCHING_EXCEPTIONS_DISABLE

#ifdef OP_FAST_MATH
#	define UX_FAST_MATH
#endif
#define UX_MATH_REAL_LIMITS

#define UX_OPT_DELEGATE_INTERFACE_SIZE			(sizeof(void*)*8)
#define UX_OPT_FUNCTION_INTERFACE_SIZE			(sizeof(void*)*32)


// disable some classes
#define _UXS_VARIABLE_ARGUMENTS_H


#if defined( __UX_DEBUG__ ) && defined( _MSC_VER )
#	define __LOG_SHOW_WARNING( _type, _text )	if ( ELog::IsError( _type ) ) { WARNING( _text ); }
#else
#	define __LOG_SHOW_WARNING( _type, _text )
#endif

#define LOG( _text, _type )						LOG_EXT( _text, _type, __FILE__, __LINE__ )

#ifdef __UX_FAST__
#	define LOG_EXT( _text, _type, _file, _line )	void()
#else
#	define LOG_EXT( _text, _type, _file, _line )	\
	{ \
		__engine_write_to_log( _text, _type, _file, _line ); \
		\
		__LOG_SHOW_WARNING( _type, _text ); \
	}
#endif	// __UX_FAST__


#define __UX_OPT_DEFAULT_LOG_ERROR		ELog::DEF_ERROR
#define __UX_OPT_DEFAULT_LOG_WARNING	ELog::DEF_WARNING


namespace Engine
{

	//
	// Log Message Type
	//

	namespace ELog
	{
		enum type
		{
			DEBUG = 0,
			INFO,
			WARN,
			ERROR,
			FATAL,
			_SRC_FILE,

			// for CHECK_* macro
			DEF_ERROR	= ERROR,
			DEF_WARNING	= WARN,

			_COUNT
		};

		inline bool IsError (type e)
		{
			return e > INFO;
		}
	}

	extern void __engine_write_to_log (const char *msg, ELog::type type, const char *file, int line);

}	// Engine
